package com.qf.ym.service;

import com.qf.ym.mapper.RoleMapper;
import com.qf.ym.entity.RoleEntity;
import com.qf.ym.pojo.RolePojo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    RoleMapper roleMapper;

    @Override//查询角色信息
    public List<RolePojo> queryRoles(RoleEntity re) {
        return roleMapper.queryRoles(re);
    }

    @Override//添加用户权限信息
    public boolean addRole(RoleEntity re) {
            //添加角色基础信息
        boolean  rs= roleMapper.addRole(re);

        //添加用户权限信息
        return roleMapper.addRoleAuths(re);


    }

    @Override//编辑角色信息
    public boolean editRole(RoleEntity re) {
        //编辑角色非权限信息
        roleMapper.editRole(re);
        //删除角色权限信息
        roleMapper.deleteRoleAuths(re);
        //添加角色新的权限信息
        roleMapper.addRoleAuths(re);

        return true;

    }
    //通过id查询角色信息
    @Override
    public RolePojo queryRolesBid(int rid) {
        return roleMapper.queryRolesBid(rid);
    }
}
